package cn.edu.nit.sys.controller;

import cn.edu.nit.sys.entity.Dict;
import cn.edu.nit.sys.mapper.DictMapper;
import cn.edu.nit.sys.service.DictService;
import cn.edu.nit.sys.utils.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author xiaobai
 * @Date 2022/10/30 21:24
 * @Version 1.0.0
 */
@RestController
@RequestMapping("/dict")
public class DictController {

    @Autowired
    private DictService dictService;

    @PostMapping
    public R addDict(@RequestBody Dict dict) {
        return dictService.addDict(dict);
    }

    @GetMapping
    public R getList(String label, String value, Page<Dict> page) {
        return dictService.getList(label, value, page);
    }

    @PutMapping
    public R updateDict(@RequestBody Dict dict) {
        return dictService.updateDict(dict);
    }

    @DeleteMapping("/{id}")
    public R delDict(@PathVariable("id")Integer id) {
        return dictService.delDict(id);
    }
}
